<template>
  <Layout>
    <div class="tags">
      <router-link class="tag" v-for="tag in tags" :key="tag.id" :to="`/labels/edit/${tag.id}?name=${tag.name}`">
        <span>{{tag.name}}</span>
        <Icon name="right" />
      </router-link>
    </div>
    <div class="createTag-wrapper">
      <Button class="createTag" @click="createTag">新建标签</Button>
    </div>
  </Layout>
</template>

<script lang="ts">
import Vue from "vue"
import {Component} from "vue-property-decorator";
import Button from '@/components/Button.vue';
import { mixins } from "vue-class-component";
import {TagHelper as tagHelper} from '@/mixins/TagHelper'

@Component({
  components: {
    Button,
  },
})
export default class Labels extends mixins(tagHelper){
  get tags(){
      return this.$store.state.tagList;
  }
  
  beforeCreate(){
    this.$store.commit('fetchTags');
  }
}
</script>

<style scoped lang="scss">
    .tags{
        background: white;
        font-size: 16px;
        > .tag{
            min-height: 44px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom:1px solid #e6e6e6;
            margin-left: 16px;
            svg{
                width: 18px;
                height: 18px;
                color: #666;
                margin-right: 16px;
            }
        }
    }
    .createTag{
        &-wrapper{
            text-align: center;
            padding: 16px;
        }
    }
</style>
